package com.SpringMVC.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.SpringMVC.dao.TCompanyMessageMapper;
import com.SpringMVC.dao.TLoginMessageMapper;
import com.SpringMVC.dao.TUserMapper;
import com.SpringMVC.model.TCompanyMessage;
import com.SpringMVC.model.TLoginMessage;
import com.SpringMVC.model.TUser;
import com.SpringMVC.service.ILoginService;

//service 代表LoginServiceImpl 这个类作为bean 被注入  name=loginServiceImpl
@Service("loginServiceImpl")
public class LoginServiceImpl implements ILoginService {
	
	private TUserMapper userMapper;
	private TLoginMessageMapper loginMessageMapper;
	private TCompanyMessageMapper companyMessageMapper;
	
	
	
	public TCompanyMessageMapper getCompanyMessageMapper() {
		return companyMessageMapper;
	}
	@Autowired
	public void setCompanyMessageMapper(TCompanyMessageMapper companyMessageMapper) {
		this.companyMessageMapper = companyMessageMapper;
	}

	public TLoginMessageMapper getLoginMessageMapper() {
		return loginMessageMapper;
	}

	@Autowired
	public void setLoginMessageMapper(TLoginMessageMapper loginMessageMapper) {
		this.loginMessageMapper = loginMessageMapper;
	}


	public TUserMapper getUserMapper() {
		return userMapper;
	}


	@Autowired
	public void setUserMapper(TUserMapper userMapper) {
		this.userMapper = userMapper;
	}



	public TUser loginService(String userName) {
		
		TUser t=userMapper.selectByUserName(userName);
		
		return t;
	}


	@Override
	public void updatePwd(String tUserPwd,String tUserName) {
		userMapper.updatePwd(tUserPwd,tUserName);
		
	}
	public List<TUser> selectAll() {
		
		return userMapper.selectAll();
	}


	
	public int addUser(TUser tuser) {
		return userMapper.insertSelective(tuser);
		
	}


	@Override
	public int deleteUser(String tUserName) {
		return userMapper.deleteByUserName(tUserName);
		
	}


	//用于插入登录信息
	public int addLoginMessage(TLoginMessage tLoginMessage) {
		loginMessageMapper.insert(tLoginMessage);
		return 0;
	}

	@Override
	public List<TLoginMessage> selectAllLoginMessage() {
		List list=loginMessageMapper.selectLoginMessage();
		return list;
	}

	@Override
	public List<TLoginMessage> search(String name) {
		List list=loginMessageMapper.selectByUserName(name);
		return list;
	}

	@Override
	public List<TCompanyMessage> getCompanyMessage() {
		List list=companyMessageMapper.selectAllCompanyMessage();
		return list;
	}

}
